﻿#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

class Solution
{
public:
    // 870. 优势洗牌
    vector<int> advantageCount(vector<int>& nums1, vector<int>& nums2)
    {
        int n = nums1.size();
        vector<int> index(n);
        for (int i = 0; i < n; ++i)
            index[i] = i;
        sort(index.begin(), index.end(), [&nums2](const int i, const int j)
            {
                return nums2[i] < nums2[j];
            });
        sort(nums1.begin(), nums1.end());

        int left = 0, right = n - 1;
        vector<int> ret(n);
        for (auto x : nums1)
        {
            if (x > nums2[index[left]])
                ret[index[left++]] = x;
            else
                ret[index[right--]] = x;
        }
        return ret;
    }

    // 409. 最长回文串
    int longestPalindrome(string s)
    {
        int hash[256] = { 0 };
        for (auto ch : s)
            hash[ch]++;
        int ret = 0;
        for (auto x : hash)
            ret += x / 2 * 2;
        if (ret < s.size())
            ret++;
        return ret;
    }
};

int main()
{
    /*vector<int> nums1{ 2,7,11,15 };
    vector<int> nums2{ 1,10,4,11 };
    vector<int> ret=Solution().advantageCount(nums1, nums2);
    for (auto x : ret)
        cout << x << " ";
    cout << endl;*/

    string s = "abccccdd";
    cout << Solution().longestPalindrome(s) << endl;

    return 0;
}